import { Component,Inject } from '@angular/core';
import { IonicPage, App, NavController, ModalController } from 'ionic-angular';

// service
import { LoadingService } from '../../../providers/utils/loading.service';
import { HideBarsService } from '../../../providers/utils/hideBars.service';

import { Storage } from '@ionic/storage';
// 常量
import * as PageConstant from '../../../constant/pageConstant';
/**
 * 设置
 */
@IonicPage()
@Component({
  selector: 'page-setting',
  templateUrl: 'settings.html',
})
export class SettingsPage {

  // private setting={
  //   cache :'20M'
  // };

  constructor(
    private navCtrl: NavController,
    private appCtrl: App,
    private modalCtrl: ModalController,
    @Inject('auth') private authService,
    private storage: Storage,
    private loadingCtrl : LoadingService,
    private hideBars: HideBarsService,
  )
  {
  }

  /*** 当页面即将进入并成为活动页面时运行。
   * */
  ionViewWillEnter()
  {
    this.hideBars.changeTabBarsElementBottom('-5rem');
  }

  /*** 离开取消订阅
   * */
  ionViewWillLeave()
  {
    this.hideBars.changeTabBarsElementBottom('0');
  }


  /*** 打开关于我们
   * */
  doAbout()
  {
    this.navCtrl.push(PageConstant.AboutPage);
  }


  /*** 打开回馈
   * */
  public doFeedback(): void
  {
    this.navCtrl.push(PageConstant.FeedbackPage);
  }

  /*** 打开重置密码
   * */
  public doResetPassword(): void
  {
    this.navCtrl.push(PageConstant.ResetPasswordPage);
  }


  /*** 退出登录
   * */
  doLogin()
  {
    this.authService.unAuth(this.appCtrl, this.modalCtrl);
  }

  /*** 清除缓存
   * */
  executeClearCache() {
    this.loadingCtrl.create('正在清理..',1000);
    this.storage.clear().then(data=> {
      /*setTimeout(()=>{
         this.setting.cache = '0M';
      },1000);*/
    });

  }

}
